<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.prime.com.tr/ui">

    <f:view contentType="text/html">
        <p:panel id="pnl" header="Task(#{systemMessageController.totalUnread})" toggleable="true" closable="false"   
                 toggleSpeed="500"   
                 toggleListener="#{systemMessageController.prepareListSystemMessage}"   
                 widgetVar="taskpanel" collapsed="true"
                 onToggleUpdate="pnl" rendered="#{loginBacking.viewSystemMessage}" > 
            <h:form id="systemmessages">
                <p:dataTable  value="#{systemMessageController.msg}" var="message" widgetVar="systemmessagetable"
                              paginator="true" rows="10"  
                              paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
                              rowStyleClass="#{(message.read) ? 'todoDone' : null}" >

                    <p:column sortBy="#{message.title}" filterBy="#{message.title}"> <f:facet name="header">
                            <h:outputText value="Notification" /> </f:facet>
                        <h:outputText value="#{message.title}" /> </p:column>

                    <p:column sortBy="#{message.sentAt.toString()}" filterBy="#{message.sentAt.toString()}"> <f:facet name="header">
                            <h:outputText value="Date Sent" /> </f:facet>
                        <h:outputText value="#{message.sentAt.toString()}" /> </p:column>

                    <p:column>
                        <p:commandButton value="Go to task" ajax="false" action="#{systemMessageController.messageSelect}">
                            <f:setPropertyActionListener value="#{message}"  
                                                         target="#{systemMessageController.selectedMessage}" /> 
                        </p:commandButton>
                    </p:column>

                    <p:column >  
                        <p:commandButton value="#{message.read?'Mark undone':'Mark done'}" 
                                         ajax="false" actionListener="#{systemMessageController.deleteMessage}" >  
                            <f:setPropertyActionListener value="#{message}" target="#{systemMessageController.messageToToggle}" />  
                        </p:commandButton>  
                    </p:column>                     

                </p:dataTable> 
            </h:form>
        </p:panel>
    </f:view>

</ui:composition>
